<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<SCRIPT LANGUAGE="JavaScript" src="../alpha.js"></SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
<!--
function f_upload(){
/*
	var w = document.getElementById("status_bar");
	w.style.position = 'absolute';
	w.style.left = document.body.clientWidth/2 - 110;
	w.style.width = 220;
	w.style.top = document.body.clientHeight/2 - 30;
	w.style.height = 60;
	w.style.lineHeight = '60px';
	w.style.backgroundColor = 'white';
	w.style.textAlign = 'center';
	var str = '<img src="'+getBaseURI()+'/image/wait.gif"/>'+'<h5>文件上传中，请等待......</h5>';
	str += '<button onclick="f_cancel()">ȡ��</button>';
	w.innerHTML = str;
*/
	if($('f1').value == ''){
		alert('请先选择文件！');
		return;
	}

	document.getElementById("status_bar").style.display = 'block';

	dojo.require("dojo.io.IframeIO");
	var bindArgs = {
		url:"?_FILE_UPLOAD_=FILEUPLOAD",
		//sync:true,				//不支持同步call。
		formNode: upload_form,
		mimetype: "text/html",
		load: function(type, data, evt){
			document.getElementById("status_bar").style.display = 'none';
			var fileName = data.body.innerHTML.split(";")[0];
			upload_form.innerHTML = '<div><a href="'+fileName+'">' 
									+ fileName.substring(fileName.lastIndexOf('/')+1, fileName.lengh)
									+ '</a>&nbsp;&nbsp;<button onclick="f_delete(\''+fileName+'\')">删除</button></div>' 
									+ upload_form.innerHTML;
			//文件上传成功后写入文件名。						
			window.parent.document.getElementById('_upload_file').value += ',' + fileName;
		}
	};
	
	dojo.io.bind(bindArgs);
}

function f_cancel(){
	var bindArgs = {
		url:"?_FILE_UPLOAD_=FILEUPLOAD&f_action=cancel",
		sync:true,
		mimetype: "text/html",
		load: function(type, data, evt){
			document.getElementById("status_bar").style.display = 'none';
		}
	};
	
	dojo.io.bind(bindArgs);
}

function f_delete(fileName){
	var bindArgs = {
		url:"?_FILE_UPLOAD_=FILEUPLOAD&F_ACTION=DELETE&F_DELETEFILE="+fileName,
		sync:true,
		mimetype: "text/html",
		load: function(type, data, evt){
			var n = event.srcElement.parentNode;
			n.parentNode.removeChild(n);
		}
	};
	
	dojo.io.bind(bindArgs);
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<form id="upload_form" enctype="multipart/form-data" method="POST">
<input type="file" name="f1">
<button onclick="f_upload();">上传</button>
</form>
<div id="status_bar" style="display:none"><img src="../image/wait.gif"/><span style="font:bold;">文件上传中，请等待......</span><button onclick="f_cancel()">取消</button></div>

</BODY>
</HTML>
